package com.qfedu.ssm.service.impl;

import com.qfedu.ssm.dao.UserDao;
import com.qfedu.ssm.entity.User;
import com.qfedu.ssm.service.intf.UserService;
import com.qfedu.ssm.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service // IOC创建类的对象
public class UserServiceImpl implements UserService {
    @Autowired // 属性注入
    private UserDao dao;

    @Override
    public R save(User user) {
        if (dao.insert(user)>0){
            return new R(200, "OK", null);
        }else {
            return new R(400, "新增用户失败", null);
        }
    }

    @Override
    public R queryAll() {
        return new R(200, "OK", dao.selectAll());
    }
}
